#pragma once

#ifndef __static_conversion_check_H__
#define __static_conversion_check_H__

#include "FLOW_core/namespace.h"

namespace CORE
{
	template< typename T, typename U >
	class CConversion
	{
		// Auxiliar struct to distinguish between one result type or another
		typedef char SmallType;
		
		struct BigType
		{
			char size2x[ 2 ];
		};

		static SmallType Test( T );
		static BigType	 Test( ... );
		static U	 MakeU( );
	public:
		enum
		{
			b_exists = ( sizeof( Test( MakeU( ) ) ) == sizeof( SmallType ) ),
			b_same_type = false
		};
	};//CConversion class
	
	//Partial Specialization for checking the same type
	template< typename T >
	class CConversion< T, T >
	{
	public:
		enum
		{
			b_exists = true,
			b_same_type = true
		};
	}; //CConversion< T, T > class 

}

#define CONVERTIBLE_POINTER_TYPES( T, U ) \
	CConversion< const T*, const U* >::b_exists

#define SUPER_SUBCLASS( T, U ) \
	( CConversion< const T*, const U* >::b_exists && \
	  !CConversion< const T*, const void* >::b_same_type )

#define SUPER_SUBCLASS_STRICT( T, U ) \
	( SUPER_SUBCLASS( T, U ) && \
	  !CConversion< T, U >::b_same_type )

#endif
